package com.tinygray.productConsumer;

import java.util.concurrent.*;

/**
 * @Author: tinygray
 * @Description: 公众号:Madison龙少，关注我你会越来越优秀。
 * @className: CallableDemo
 * @create: 2021-05-09 17:51
 */
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
        new Thread(futureTask, "AAA").start();

        int number = 100;
        System.out.println("main........");
        Thread.currentThread().join(2000);
        Integer integer = futureTask.get();
        System.out.println(integer + number);
    }
}
class MyThread implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        System.out.println("come in callable");
        return 1024;
    }
}

